load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_source", "go_test")
load("@io_bazel_rules_go//go/tools/bazel_testing:def.bzl", "go_bazel_test")
load(":def.bzl", "no_context_info")

test_suite(
    name = "cross",
)

go_binary(
    name = "windows_cross",
    srcs = ["main.go"],
    goarch = "amd64",
    goos = "windows",
    pure = "on",
    deps = [":platform_lib"],
)

go_binary(
    name = "linux_cross",
    srcs = ["main.go"],
    goarch = "amd64",
    goos = "linux",
    pure = "on",
    deps = [":platform_lib"],
)

go_binary(
    name = "darwin_cross",
    srcs = ["main.go"],
    goarch = "amd64",
    goos = "darwin",
    pure = "on",
    deps = [":platform_lib"],
)

go_library(
    name = "platform_lib",
    srcs = select({
        "//go/platform:darwin": ["lib_darwin.go"],
        "//go/platform:linux": ["lib_linux.go"],
        "//go/platform:windows": ["lib_windows.go"],
    }),
    importpath = "github.com/bazelbuild/rules_go/tests/core/cross/platform_lib",
)

go_test(
    name = "cross_test",
    size = "small",
    srcs = ["cross_test.go"],
    args = [
        "-darwin",
        "$(location :darwin_cross)",
        "-linux",
        "$(location :linux_cross)",
        "-windows",
        "$(location :windows_cross)",
    ],
    data = [
        ":darwin_cross",
        ":linux_cross",
        ":windows_cross",
    ],
    rundir = ".",
    deps = ["//go/tools/bazel:go_default_library"],
)

go_bazel_test(
    name = "ios_select_test",
    srcs = ["ios_select_test.go"],
)

go_bazel_test(
    name = "proto_test",
    srcs = ["proto_test.go"],
)

no_context_info(
    name = "no_context_info",
)
